package org.jeecg.modules.demo.znnqjc.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.demo.znnqjc.entity.ZwglZhgj;
import org.jeecg.modules.demo.znnqjc.entity.ZwglZhgjfb;
import org.jeecg.modules.demo.znnqjc.mapper.ZwglZhgjfbMapper;
import org.jeecg.modules.demo.znnqjc.mapper.ZwglZhgjMapper;
import org.jeecg.modules.demo.znnqjc.service.IZwglZhgjService;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import java.io.Serializable;
import java.util.List;
import java.util.Collection;

/**
 * @Description: 种植格局
 * @Author: jeecg-boot
 * @Date: 2023-04-21
 * @Version: V1.0
 */
@Service
public class ZwglZhgjServiceImpl extends ServiceImpl<ZwglZhgjMapper, ZwglZhgj> implements IZwglZhgjService {

    @Autowired
    private ZwglZhgjMapper zwglZhgjMapper;
    @Autowired
    private ZwglZhgjfbMapper zwglZhgjfbMapper;

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void delMain(String id) {
        zwglZhgjfbMapper.deleteByMainId(id);
        zwglZhgjMapper.deleteById(id);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void delBatchMain(Collection<? extends Serializable> idList) {
        for (Serializable id : idList) {
            zwglZhgjfbMapper.deleteByMainId(id.toString());
            zwglZhgjMapper.deleteById(id);
        }
    }


    @Override
    public Result getzzgj(String nianfen) {
        QueryWrapper<ZwglZhgj> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("psrq", nianfen);
        List<ZwglZhgj> list = zwglZhgjMapper.selectList(queryWrapper);
        return Result.OK(list);
    }
    @Override
    public Result getzzgjdkcx(String dkmc,String id) {
        QueryWrapper<ZwglZhgjfb> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("dkmc", dkmc);
        queryWrapper.like("wj",id);
        List<ZwglZhgjfb> list = zwglZhgjfbMapper.selectList(queryWrapper);
        return Result.OK(list);
    }
    @Override
    public Result getzzgjqb() {
        QueryWrapper<ZwglZhgj> queryWrapper = new QueryWrapper<>();
        List<ZwglZhgj> list = zwglZhgjMapper.selectList(queryWrapper);
        return Result.OK(list);
    }

    @Override
    public Result getzzgjdk(String dkbh) {
        QueryWrapper<ZwglZhgjfb> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("dkbh", dkbh);
        List<ZwglZhgjfb> list = zwglZhgjfbMapper.selectList(queryWrapper);
        return Result.OK(list);
    }

    @Override
    public Result getzzgjzdfxzuo(String nianfen) {
        QueryWrapper<ZwglZhgj> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("psrq", nianfen);
        List<ZwglZhgj> list = zwglZhgjMapper.selectList(queryWrapper);
        return Result.OK(list);
    }

    @Override
    public Result getzzgjzdfxyou(String nianfen) {
        QueryWrapper<ZwglZhgj> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("psrq", nianfen);
        List<ZwglZhgj> list = zwglZhgjMapper.selectList(queryWrapper);
        return Result.OK(list);
    }

}
